package com.ylsf.blog.controller;

import com.ylsf.blog.service.SubmitService;
import com.ylsf.blog.service.impl.SubmitServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 注册控制类
 */
@WebServlet("/submit")
public class SubmitServlet extends HttpServlet {
    private SubmitService submitService=new SubmitServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("utf-8");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        /*
        System.out.println(submitService.judgeUsername(username));
        System.out.println("******111");
        System.out.println(submitService.judgePassword(password));*/
        if(submitService.judgeUsername(username)&&submitService.judgePassword(password)){
            submitService.submitUsernamePwd(username,password);
            response.getWriter().print("success");
        }
    }
}
